#include <bits/stdc++.h>

using namespace std;

int num[100010];

int main()
{
    int count = 0;
    int n, res1, res2;
    cin >> n;
    while (cin >> num[count++])
    {
    }
    sort(num, num + count);
    for (int i = 1; i <= count; ++i)
    {
        if (num[i - 1] == num[i])
        {
            res2 = num[i - 1];
        }
        else if (num[i - 1] + 2 <= num[i])
        {
            res1 = num[i - 1] + 1;
        }
    }
    cout << res1 << " " << res2 << endl;
    return 0;
}